import Vue from 'vue';
import Vuex from 'vuex';

Vue.use(Vuex);

const store = new Vuex.Store({
	state: {
		navHeight: null,
		topic: {},
		city: '',
		curLocation: {},
	},
	mutations: {
		setNavH(state, val) {
			state.navHeight = val;
		},
		setTopic(state, val) {
			if(val === null) {
				state.topic = {};
			}else {
				state.topic[val.tpid] = val;
			}
		},
		setCity(state, val) {
			state.city = val;
		},
		setCurLocation(state, val) {
			state.curLocation = val;
		}
	},
});

export default store;